import java.util.Arrays;
import java.util.Scanner;

public class 找终点{

    public static void main(String[] args) {
        
        Scanner scanner = new Scanner(System.in);

        //找到第一行，按空格解析出输入数据
        int[] inputArr = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();

        //
        if(1 == inputArr.length){

            System.out.println(""+1);

        } else{

            int len = inputArr.length;

            //记录最小步数  100 为数组长度
            int minS = 100;

            //循环遍历
            for(int i=1; i<len /2; i++){

                int step =1;
                int nextPosition = i+inputArr[i];

                step++;

                while (nextPosition < len - 1) {
                    nextPosition += inputArr[nextPosition];
                    step++;
                }

                //走到最后一步
                if(nextPosition == len -1){

                    minS = Math.min(step, minS);
                }

            }

            System.out.println(minS == 100 ? "-1" : ""+minS);

        }
    }
}